package mo.offer_special;

import mo.common.ListNode;

public class L024 {

    public ListNode reverseList(ListNode head) {
        if (head == null) {
            return null;
        }
        ListNode res = new ListNode(head.val);
        while (head.next != null) {
            ListNode current = new ListNode(head.next.val);
            current.next = res;
            res = current;
            head = head.next;
        }

        return res;
    }

}
